﻿using HalconDotNet;
using NDK.Module.BLL;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NDK.Module.Model
{
    public class DataItem
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public double Value { get; set; }
        public int Position { get; set; }
        public string JugeResult { get; set; }
        public int Remark { get; set; }
        public double NormValue { get; set; }
        public double UpperDeviation { get; set; }
        public double LowerDeviation { get; set; }
        public bool IsShow { get; set; }
        public bool IsJudging { get; set; }
        public double K { get; set; }
        public double B { get; set; }
        public double B1 { get; set; }
    }
    public enum batteryType
    {
        Bottom = 0,
        PostBottom = 1,
        Book = 2,
        PostBook = 3
    }
    public class Battery : MeasureProduct
    {
        public int R1TurnNo { get; set; }
        public int R2TurnNo { get; set; }

        public int NotchPlug { get; set; }//0:没贴NotchPlug，1：贴了NotchPlug

        private List<DataItem> _measureData = new List<DataItem>();

        public Battery() : base()
        {
            _measureData = new List<DataItem>();
        }
    }

    public class MeasureProduct
    {
        public string SN { get; set; }
        public string Line { get; set; }
        public string NG_FAI { get; set; }
        public string OK_NG { get; set; }
        public string Position { get; set; }
        public string MesInfo { get; set; }
        public string StrInCheck { get; set; }
        public string StrOutCheck { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public List<Task> tasks { get; set; }

        public HImage SideCam_1 { get; set; } = null;
        public HImage SideCam_2 { get; set; } = null;
        public HImage SideCam_3 { get; set; } = null;

        public HImage UpLaser { get; set; } = null;

        public HImage SideLaser_短边1_1 { get; set; } = null;
        public HImage SideLaser_短边2_1 { get; set; } = null;
        public HImage SideLaser_短边3_1 { get; set; } = null;
        public HImage SideLaser_短边4_1 { get; set; } = null;
        public HImage SideLaser_短边4_2 { get; set; } = null;
        public HImage SideLaser_短边3_2 { get; set; } = null;
        public HImage SideLaser_长边1_3 { get; set; } = null;
        public HImage SideLaser_长边2_3 { get; set; } = null;
        public HImage SideLaser_长边3_3 { get; set; } = null;
        public HImage SideLaser_长边4_3 { get; set; } = null;
        public HImage SideLaser_长边3_4 { get; set; } = null;
        public HImage SideLaser_长边1_4 { get; set; } = null;
        public HImage SideLaser_长边4_4 { get; set; } = null;


        public HImage DownLaser1 { get; set; } = null;
        public HImage DownLaser2 { get; set; } = null;
        public HImage MidLaser1 { get; set; } = null;

        public HImage UpCamImage_1 { get; set; } = null;
        public HImage UpCamImage_2 { get; set; } = null;
        public HImage UpCamImage_3 { get; set; } = null;
        public HImage UpCamImage_4 { get; set; } = null;

        public List<MeasureSize> measureSizeList { get; set; }

        public JUDGEMENT_RESULT Result { get; set; }

        public int ProductID { get; set; }
        public bool IsClear_PLC { get; set; }

        public int whichBlock { get; set; }//-1 正常产品，0 Nom， 1 Max， 2 Min

        private List<DataItem> _measureData = new List<DataItem>();

        static readonly object obj = new object();
        public List<DataItem> MeasureData
        {
            get
            {
                lock (obj)
                {
                    return _measureData;
                }
            }
            set
            {
                lock (obj)
                {
                    _measureData = value;
                }
            }
        }

        public MeasureProduct()
        {
            SN = "";
            NG_FAI = "";
            Position = "";
            _measureData = new List<DataItem>();
            ProductID = 0;

            MeasureData = new List<DataItem>();
            tasks = new List<Task>();
            Result = JUDGEMENT_RESULT.EMPTY;
        }
    }
}
